Skip to content

azure: add Ignition config generation from IMDS/OVF metadata - #2

Closed
peytonr18 wants to merge 7 commits into
mainfrom
probertson-updated-ignition-demo2
Closed

azure: add Ignition config generation from IMDS/OVF metadata#2
peytonr18 wants to merge 7 commits into
mainfrom
probertson-updated-ignition-demo2

Conversation

@peytonr18

Copy link
Copy Markdown
Owner

Summary

This PR adds support for generating an Ignition config from Azure's IMDS and ovf provisioning data.

Usage

Enable via kernel command line:
ignition.config.generate=azure

When enabled, Ignition generates a config that creates:

  • Admin user with the username from Azure
  • SSH authorized keys from both IMDS and OVF sources
  • Hashed password (if provided)
  • Sudoers rule for passwordless sudo (%wheel ALL=(ALL) NOPASSWD:ALL)
  • SSHD configuration based on Azure's DisableSshPasswordAuthentication setting

Kernel cmdline ignition-generator ignition binary:

  • ignition.config.generate=azureIGNITION_ARGS=--generate... → GenerateCloudConfig()
  • Proceeds to fetch IMDS, parse OVF, and build the config.

Changes

New Files

  • internal/providers/azure/crypt.go - SHA-512 password hashing utilities

Modified Files

  • internal/platform/platform.go - Added GenerateCloudConfig to Provider interface
  • internal/main.go - Added --generate-cloud-config CLI flag
  • internal/exec/engine.go - Added generation mode handling
  • internal/providers/azure/azure.go - Core generation logic
  • dracut/30ignition/ignition-generator - Kernel cmdline parsing

Dependencies

  • Added github.com/GehirnInc/crypt for SHA-512 password hashing

Add support for generating an Ignition config from Azure's Instance
Metadata Service (IMDS) and OVF provisioning data. This allows VMs to
be provisioned with the admin user, SSH keys, and password configured
in Azure without requiring a user-provided Ignition config.

This feature is opt-in via kernel cmdline parameter:
  ignition.config.generate=azure

When enabled, Ignition will:
- Fetch extended metadata from IMDS (/metadata/instance?extended=true)
- Mount the provisioning CD-ROM and parse ovf-env.xml
- Generate an Ignition config with:
  - Admin user (from IMDS osProfile.adminUsername or OVF UserName)
  - SSH authorized keys (from both sources, deduplicated)
  - Hashed password (SHA-512 crypt format)
  - Sudoers config for passwordless sudo
  - SSHD config based on DisableSshPasswordAuthentication setting

Key implementation details:
- Added GenerateCloudConfig to platform.Provider interface
- Added --generate-cloud-config CLI flag to ignition binary
- Password hashing uses github.com/GehirnInc/crypt library
- OVF reading has 30-second timeout to prevent boot hangs
- Fixed yes/no parsing for DisableSshPasswordAuthentication field
@peytonr18
peytonr18 requested a review from Copilot December 2, 2025 19:42
@peytonr18 peytonr18 changed the title Ignition Config Demo azure: add Ignition config generation from IMDS/OVF metadata Dec 2, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces support for generating Azure-specific Ignition configurations from Azure Instance Metadata Service (IMDS) and OVF provisioning data. The feature is activated via the kernel command-line parameter ignition.config.generate=azure, enabling automatic admin user provisioning with SSH keys, password authentication settings, sudo permissions, and SSHD configuration based on Azure metadata.

Key changes include:

  • Added password hashing utilities using SHA-512 crypt algorithm via the github.com/GehirnInc/crypt library
  • Implemented cloud config generation capability as a new provider interface method (GenerateCloudConfig)
  • Enhanced kernel command-line parsing to support config generation mode with validation against command injection

Reviewed changes

Copilot reviewed 9 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
vendor/modules.txt Added github.com/GehirnInc/crypt dependency for password hashing
vendor/github.com/GehirnInc/crypt/** Vendored password hashing library implementing SHA-512 crypt
internal/providers/azure/crypt.go Password hashing wrapper functions for SHA-512 with hash detection
internal/providers/azure/azure_test.go Comprehensive test suite covering config generation, password handling, username priority, and edge cases
internal/providers/azure/azure.go Core generation logic: IMDS fetching, OVF parsing, config building, and device mounting refactoring
internal/platform/platform.go Added GenerateCloudConfig to Provider interface and corresponding wrapper method
internal/main.go Added --generate-cloud-config CLI flag for generation mode
internal/exec/engine.go Implemented config generation path with platform validation and state tracking
dracut/30ignition/ignition-generator Kernel cmdline parsing with regex validation to prevent command injection
go.mod, go.sum Added crypt library dependency at version v0.0.0-20230320061759-8cc1b52080c5
docs/release-notes.md Documented new Azure config generation feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/providers/azure/azure.go
Comment thread internal/providers/azure/azure.go
Comment thread internal/providers/azure/azure.go
Comment thread internal/providers/azure/azure.go
Comment thread internal/platform/platform.go
Comment thread internal/providers/azure/azure.go
@peytonr18

Copy link
Copy Markdown
Owner Author

closing in favor of #4

@peytonr18 peytonr18 closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants